# 暂时不支持自动生成img文件，所以能正确运行的前提是提前准备好img文件，只有源码文件是不行的
MOD_NAME = pmtest6
build: $(MOD_NAME).img $(MOD_NAME)_boot.img

$(MOD_NAME).img: $(MOD_NAME).com
	sudo mount -o loop $@ /mnt/floppy
	sudo rm -fr /mnt/floppy/$<
	sudo cp $< /mnt/floppy/
	sudo umount /mnt/floppy

$(MOD_NAME)_boot.img: $(MOD_NAME)_boot.bin
	dd if=$< of=$@ bs=512 count=1 conv=notrunc

$(MOD_NAME).com: $(MOD_NAME).asm
	nasm -o $@ $<

$(MOD_NAME)_boot.bin: $(MOD_NAME)_boot.asm
	nasm -o $@ $<

clean:
	rm -rf *.com *.bin
